<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>#{msg.page_addCar}</title>
    <f:view locale="#{userBean.locale}"/>

</h:head>
<h:body>


    <ui:decorate template="/sample.xhtml">
        <ui:define name="body">

            <br/>
            <h1>#{msg.text_addAdver}</h1>
            <br/>
            <h:panelGroup id="keyParameters" rendered="#{!addCar.next}">
                <h:form>
                    <table border="0">
                        <tr style="text-align: center">
                            <td>#{msg.text_AddAdverBrand}</td>
                            <td>#{msg.text_AddAdverModel}</td>
                            <td>#{msg.text_AddAdverColor}</td>
                            <td>#{msg.text_AddAdverCondition}</td>
                            <td>#{msg.text_AddAdverTypeEngine}</td>
                            <td>#{msg.text_AddAdverTransmission}</td>
                            <td>#{msg.text_AddAdverPrivod}</td>
                            <td>#{msg.text_AddAdverBodyType}</td>

                        </tr>
                        <tr style="text-align: center">
                            <td>
                                <h:selectOneMenu id="brand"
                                                 validatorMessage="!"
                                                 value="#{addCar.brandId}" onchange="submit()"
                                                 valueChangeListener="#{addCar.brandSet}"       >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.brands}" var="brandItem"
                                                   itemLabel="#{brandItem.nameEn}" itemValue="#{brandItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="brand"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu id="model"
                                                 validatorMessage="!" value="#{addCar.modelId}" onchange="submit()"
                                                 valueChangeListener="#{addCar.modelSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.models}" var="modelItem"
                                                   itemLabel="#{modelItem.nameEn}" itemValue="#{modelItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="model"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu id="color"
                                                 validatorMessage="!" value="#{addCar.colorId}" onchange="submit()"
                                                 valueChangeListener="#{addCar.colorSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.colors}" var="colorItem"
                                                   itemLabel="#{colorItem.nameRu}" itemValue="#{colorItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="color"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu  id="condition"
                                                  validatorMessage="!" value="#{addCar.conditionId}" onchange="submit()"
                                                  valueChangeListener="#{addCar.conditionSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.conditions}" var="conditionItem"
                                                   itemLabel="#{conditionItem.nameRu}" itemValue="#{conditionItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="condition"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu
                                        id="typeEngine"
                                        validatorMessage="!"
                                        value="#{addCar.typeEngineId}" onchange="submit()"
                                        valueChangeListener="#{addCar.typeEngineSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.typeEngines}" var="typeEnginesItem"
                                                   itemLabel="#{typeEnginesItem.nameRu}" itemValue="#{typeEnginesItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="typeEngine"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu
                                        id="transmission"
                                        validatorMessage="!"
                                        value="#{addCar.transmissionId}" onchange="submit()"
                                        valueChangeListener="#{addCar.transmissionSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.transmissions}" var="transmissionItem"
                                                   itemLabel="#{transmissionItem.nameRu}" itemValue="#{transmissionItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="transmission"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu
                                        id="privod"
                                        validatorMessage="!"
                                        value="#{addCar.privodId}" onchange="submit()"
                                        valueChangeListener="#{addCar.privodSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.privods}" var="privodItem"
                                                   itemLabel="#{privodItem.nameRu}" itemValue="#{privodItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="privod"  style="color: red; font-size: 25px" />

                            </td>
                            <td>
                                <h:selectOneMenu
                                        id="bodyType"
                                        validatorMessage="!"
                                        value="#{addCar.bodyTypeId}" onchange="submit()"
                                        valueChangeListener="#{addCar.bodyTypeSet}"        >
                                    <f:selectItem itemValue="0" itemLabel="---"/>
                                    <f:selectItems value="#{car.bodyTypes}" var="bodyTypeItem"
                                                   itemLabel="#{bodyTypeItem.nameRu}" itemValue="#{bodyTypeItem.id}" />
                                    <f:validateLongRange minimum="1"/>
                                </h:selectOneMenu>
                                <h:message  for="bodyType"  style="color: red; font-size: 25px" />


                            </td>
                        </tr>
                    </table>

                    <br/>
                    #{msg.text_AddAdverPrice} :
                    <h:inputText id="price" validatorMessage="!" value="#{addCar.price}">
                        <f:validateDoubleRange maximum="10000000" minimum="10"/>
                    </h:inputText>
                    <h:message  for="price"  style="color: red; font-size: 25px" />
                    <h:selectOneMenu
                            id="currency"
                            validatorMessage="!"
                            value="#{addCar.currencyId}" onchange="submit()"
                            valueChangeListener="#{addCar.currencySet}"        >
                        <f:selectItem itemValue="0" itemLabel="---"/>
                        <f:selectItems value="#{car.currencies}" var="currenciItem"
                                       itemLabel="#{currenciItem.shortnameEn}" itemValue="#{currenciItem.id}" />
                        <f:validateLongRange minimum="1"/>
                    </h:selectOneMenu>
                    <h:message  for="currency"  style="color: red; font-size: 25px" />
                    <br/>
                    #{msg.text_AddAdverValue}
                    <h:inputText value="#{addCar. volume}"/>
                    <br/>
                    #{msg.text_AddAdverDate} <h:inputText id="date" value="#{addCar.date}"
                                                          size="20" required="true"
                                                          requiredMessage="#{msg.text_date}"
                                                          validatorMessage="#{msg.text_date}">

                    <f:convertDateTime pattern="d-M-yyyy" />
                </h:inputText>
                    (01-01-1990)
                    <h:message for="date" style="color:red" /> <br/>
                    <br/>
                    #{msg.text_AddAdberDescription} <br/>
                    <h:inputTextarea value="#{addCar.description}" rows="4" cols="50"  />

                    <br/><br/><br/>
                    <h:commandButton value="#{msg.text_AddAdverCancel}" action="index" immediate="true"/>
                    <h:commandButton value="#{msg.text_AddAdvetNext}" action="#{addCar.resume}"/>
                </h:form>
            </h:panelGroup>
            <br/>
            <h:panelGroup id="otherOptions" rendered="#{addCar.next}">
                <h:form>
                    <table border="1">
                        <tr style="text-align: center">
                            <td>#{msg.text_AddAdverBrand}</td>
                            <td>#{addCar.car.transport.brand.nameEn}</td>

                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverModel}</td>
                            <td>#{addCar.car.model.nameEn}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverColor}</td>
                            <td>#{addCar.car.transport.color.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverCondition}</td>
                            <td>#{addCar.car.transport.condition.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverTypeEngine}</td>
                            <td>#{addCar.car.typeEngine.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverTransmission}</td>
                            <td>#{addCar.car.transmission.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverPrivod}</td>
                            <td>#{addCar.car.privod.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverBodyType}</td>
                            <td>#{addCar.car.bodyType.nameRu}</td>
                        </tr>
                        <tr>
                            <td>#{msg.text_AddAdverPrice}</td>
                            <td>#{addCar.car.transport.price}</td>
                        </tr>

                        <tr>
                            <td>#{msg.text_AddAdverDate}</td>
                            <td>#{addCar.car.transport.date}</td>
                        </tr>
                    </table>
                    <h:commandButton value="#{msg.text_AddAdverCancel}" action="index" immediate="true"/>
                    <h:commandButton value="#{msg.text_AdverAdd}" action="#{addCar.addAdver}"/>
                </h:form>

            </h:panelGroup>






        </ui:define>
    </ui:decorate>










</h:body>
</html>


